package edu.sctu.xiangkun.day201506.day20150606;


import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
 * Created by user21 on 2015/6/6.
 */
public class EnterAndExit {

    List<Passenger> passengerList = new SetPassengerInfo().setPassengerInfo();
    LuggageOfPassenger passengerOfXiingli = new LuggageOfPassenger();

    public void enterAndExit() {
        Random random = new Random();
        for(int i = 0;i < passengerList.size();i++){

            System.out.println("姓名：" + passengerList.get(i).getName() + "\n编号："
                    + passengerList.get(i).getNumber());

            System.out.println("起点站："+passengerList.get(i).getStartStation()+
                    "  终点站："+passengerList.get(i).getEndStation());


            if (passengerList.get(i).isIs_Card()) {

                if (passengerList.get(i).isIs_Package()) {

                    if (passengerOfXiingli.isPackage(i)) {

                        System.out.println("行李可能含有危险物品，请检查后再入站");

                    } else {
                        System.out.println("进站");

                        DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.LONG);
                        Calendar calendar = Calendar.getInstance();
                        Date date = calendar.getTime();
                        System.out.println("进站时间 : "+dateFormat.format(date));
                    }

                    if (passengerList.get(i).isIs_Water()) {
                        if (passengerOfXiingli.isWater(i)) {

                            System.out.println("水可能含有危险物品，请检查后再入站");
                        } else {

                            System.out.println("进站");

                            DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.LONG);
                            Calendar calendar = Calendar.getInstance();
                            Date date = calendar.getTime();
                            System.out.println("进站时间 : "+dateFormat.format(date));

                        }
                    }
                }
                if (new HandleCard().getPrice() <= passengerList.get(i).getCardBalance()) {

                    System.out.println("请刷卡出站");

                    System.out.println();

                } else {
                    new HandleCard().setRecharge(10, passengerList.get(i));
                    System.out.println("充值成功，余额为" + (passengerList.get(i).getCardBalance()
                            - new HandleCard().getPrice()));

                    System.out.println("出站");

                        DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.LONG);
                        Calendar calendar = Calendar.getInstance();
                        calendar.add(calendar.MINUTE,(random.nextInt(20)));
                        Date date = calendar.getTime();
                        System.out.println("出站时间 : " + dateFormat.format(date));
                }

            } else {

                System.out.println("你需要办卡才能入站坐车");

                System.out.println("你需付费" + new HandleCard().getPrice() + "元");

                if (passengerList.get(i).isIs_Package()) {

                    if (passengerOfXiingli.isPackage(i)) {

                        System.out.println("行李可能含有危险物品，请检查后再入站");
                    }
                    if (passengerOfXiingli.isWater(i)) {

                        System.out.println("水可能含有危险物品，请检查后再入站");
                    } else {

                        System.out.println("进站");

                        DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.LONG);
                        Calendar calendar = Calendar.getInstance();
                        Date date = calendar.getTime();
                        System.out.println("进站时间 : "+dateFormat.format(date));
                    }
                    System.out.println("出站");

//                        int j = handleCard.getCountStation(Passenger.getStartStation(), Passenger.getEndStation());
                        DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.LONG);
                        Calendar calendar = Calendar.getInstance();
                        calendar.add(calendar.MINUTE, (random.nextInt(20)));
                        Date date = calendar.getTime();
                        System.out.println("出站时间 : " + dateFormat.format(date));

                    System.out.println();
                }
            }
        }
    }
}
